

# MMDS Server Console v0.1


# MMDS Database Creation 

import os

import sys

import MySQLdb

try:
	
	db = MySQLdb.Connect(host="127.0.0.1", port=3306, user="root", passwd="")

except MySQLdb.Error, e:
     print "Error %d: %s" % (e.args[0], e.args[1])
     sys.exit (1)
     
cursor = db.cursor()

sql = "CREATE DATABASE mmds"

print "\nCreating Databases ....."

cursor.execute(sql)


print "\nmmds database created successfully..."

db.close()

db = MySQLdb.Connect(host="127.0.0.1", port=3306, user="root", passwd="",db="mmds")

sql1= "Create table mmds_userinfo(userid int(9), studname  varchar(20) ,passwd  varchar(10),class  varchar(10),coursename  varchar(10),coursecode  varchar(10),labsess  varchar(10),sysno  int(5),doe varchar(10))"

sql2 = 'Create table temp1(username varchar(20),term varchar(6), date varchar(10), time varchar(6),ipaddr varchar(20)'

sql3 = 'Create table temp2(username varchar(20),term varchar(6), date varchar(10), time varchar(6),ipaddr varchar(20)'

cursor = db.cursor()

print "\nCreating Tables ....."

cursor.execute(sql1)

cursor.execute(sql2)

cursor.execute(sql3)

print "\nmmds_userinfo table created successfully..."

result = cursor.fetchall()

print  "\nEverything is done...\n\n"

db.close()
